package com.gpnu.crm.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;

import com.gpnu.crm.domain.CustomerTransfer;
import com.gpnu.crm.domain.Employee;
import com.gpnu.crm.query.CustomerTransferQueryObject;
import com.gpnu.crm.service.ICustomerTransferService;
import com.gpnu.crm.util.UserContext;

@Controller
@RequestMapping("/customerTransfer")
public class CustomerTransferController {
	@Autowired
	private ICustomerTransferService customerTransferService;

	@RequestMapping("/list")
	public String list(@ModelAttribute("qo") CustomerTransferQueryObject qo, Model model) {
		PageInfo<CustomerTransfer> info = customerTransferService.list(qo);
		model.addAttribute("pageInfo", info);
		return "customerTransfer/list"; 
	}
	
	@RequestMapping("/save")
	public String save(CustomerTransfer e){
		Employee loginUser = UserContext.getCurrentUser();
		e.setOperator(loginUser);
		
		customerTransferService.save(e);
		return "redirect:/customerTransfer/list.do";
	}
}
